package org.scut.smartgeometry.utils;

import org.scut.smartgeometry.view.identify_system.SGPoint;

/**
 * Created by Administrator on 13-7-11.
 */
public class Utils {

    public static float getDisTwoPoints(SGPoint p1, SGPoint p2){

        float dis = (float) Math.pow(
                (p1.getX() - p2.getX()) * (p1.getX() - p2.getX())
                + (p1.getY() - p2.getY()) * (p1.getY() - p2.getY())
                , 0.5
        );

        return dis;
    }


    public static float getSForTriagle(SGPoint p1, SGPoint p2, SGPoint p3){

        float s = 1/2f * Math.abs(
                (p2.getX()-p1.getX()) * (p3.getY()-p2.getY())
                        - (p3.getX()-p2.getX()) * (p2.getY()-p1.getY()) );

        return s;
    }


    public static float getSlope(SGPoint p1, SGPoint p2){
        float slope = (p1.getY()- p2.getY()) / (p1.getX() - p2.getX());

        return slope;
    }


}
